@extends('backend.layouts.default')

@section('content')
  <div class="box box-primary">
    <div class="box-header with-border">
      <h3 class="box-title">文章列表</h3>

      <div class="box-tools">
        <form action="{{ route('posts.index') }}">
          <div class="input-group input-group-sm" style="width: 300px;">
            <input type="text" name="query" class="form-control pull-right" value="{{ $query }}" placeholder="搜索">

            <div class="input-group-btn">
              <button type="submit" class="btn btn-default"><i class="fa fa-search"></i></button>
              <a class="btn btn-default margin-left" href="{{ route('posts.create') }}">添加</a>
            </div>
          </div>
        </form>
      </div>
    </div>
    <div class="box-body table-responsive">
      <table class="table table-hover table-bordered">
        <tr>
          <th>ID</th>
          <th>标题</th>
          <th>发布日期</th>
          <th>操作</th>
        </tr>
        @forelse ($posts as $post)
          <tr>
            <td>{{ $post->id }}</td>
            <td>{{ $post->title }}</td>
            <td>{{ $post->publish_date }}</td>
            <td>
              <a class="btn btn-default btn-xs" href="{{ route('posts.edit', $post->id) }}">编辑</a>
              <a-form class-name="btn btn-default btn-xs" action="{{ route('posts.destroy', $post->id) }}" method="delete">删除</a-form>
            </td>
          </tr>
        @empty
          <tr>
            <td colspan="4">暂无数据</td>
          </tr>
        @endforelse
      </table>
    </div>
    <div class="box-footer clearfix text-right">
      {!! $posts->render() !!}
    </div>
  </div>
@endsection
